<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
  <link href="${staticPath!}/plugins/uploadifive/uploadifive.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <#if operation== 'add'>
              <li class="active">新增公告通知信息</li>
              <#elseif operation== 'edit'>
              <li class="active">编辑公告通知信息</li>
              <#elseif operation == 'view'>
              <li class="active">查看公告通知信息</li>
              <#else>
              <li class="active">编辑公告通知信息</li>
            </#if>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="SystemNoticeMgr.returnIndex()"><i
                      class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
              <button class="btn btn-info" id="save" onclick="SystemNoticeMgr.submitForm()" type="button"><i
                      class="fa fa-save">&nbsp;&nbsp;</i>保存
              </button>
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>公告通知信息</strong>
          </div>
          <form action="/systemNotice/saveSystemNotice" class="form-horizontal" id="systemNoticeForm" method="post"
                role="form">
            <input id="operation" name="operation" type="hidden" value="${operation!}"/>
            <input id="id" name="id" type="hidden" value="${systemNotice.id!}"/>
            <div class="form-group">
              <label class="col-sm-2 control-label">公告名称：</label>
              <div class="col-sm-6">
                <input class="form-control" id="noticeName" name="noticeName" required="required"
                       type="text" value="${systemNotice.noticeName!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">公告标题：</label>
              <div class="col-sm-6">
                <input class="form-control" id="noticeTitle" name="noticeTitle" required="required"
                       type="text" value="${systemNotice.noticeTitle!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">是否发布：</label>
              <div class="col-sm-2" dicType='select' dict="std_zb_yn" id="isPublicGroup"
                   name="isPublicGroup" required="required" value="${systemNotice.isPublic!}">
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">公告内容：</label>
              <div class="col-sm-6">
                <input type="hidden" id="noticeContent" name="noticeContent" />
                <!--style给定宽度可以影响编辑器的最终宽度-->
                <script type="text/plain" id="noticeContentEditor" style="width:100%;height:240px;">
                  ${systemNotice.noticeContent!}
                  </script>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <div id="uploadqueue">
                <input id="file_upload" multiple="true" name="file_upload" type="file">
                <a href="javascript:$('#file_upload').uploadifive('upload')">上传文件</a> |
                <a href="javascript:$('#file_upload').uploadifive('stop')">停止上传</a>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
</div>
<#include "/common/umeditorlib.html">
<script src="${staticPath!}/plugins/uploadifive/jquery.uploadifive.min.js" type="text/javascript"></script>
<script type="text/javascript">
    //实例化编辑器
    var um = UM.getEditor('noticeContentEditor');
    um.addListener('blur',function(){
        $('#focush2').html('编辑器失去焦点了')
    });
    um.addListener('focus',function(){
        $('#focush2').html('')
    });
    //按钮的操作
    function insertHtml() {
        var value = prompt('插入html代码', '');
        um.execCommand('insertHtml', value)
    }
    function isFocus(){
        alert(um.isFocus())
    }
    function doBlur(){
        um.blur()
    }
    function createEditor() {
        enableBtn();
        um = UM.getEditor('noticeContentEditor');
    }
    function getAllHtml() {
        alert(UM.getEditor('noticeContentEditor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('noticeContentEditor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('noticeContentEditor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用umeditor')方法可以设置编辑器的内容");
        UM.getEditor('noticeContentEditor').setContent('欢迎使用umeditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UM.getEditor('noticeContentEditor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UM.getEditor('noticeContentEditor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UM.getEditor('noticeContentEditor').selection.getRange();
        range.select();
        var txt = UM.getEditor('noticeContentEditor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UM.getEditor('noticeContentEditor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UM.getEditor('noticeContentEditor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UM.getEditor('noticeContentEditor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UM.getEditor('noticeContentEditor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            domUtils.removeAttributes(btn, ["disabled"]);
        }
    }
</script>
<!-- form页面js -->
<script type="text/javascript">
    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        SystemNoticeMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                    $("#save").hide();
                }
                initDict(DICTURL, FORM, operation);
            },
            // init end

            // 提交数据
            submitForm: function () {
                $("#noticeContent").val(UM.getEditor('noticeContentEditor').getContent());
                Jmts.ajaxSubmit(document.getElementById("systemNoticeForm"), function (result) {
                    var operation = result.operation;
                    if (result.success) {
                        Jmts.succTips(result.msg);
                        if (operation == 'add') {
                            SystemNoticeMgr.returnIndex();
                        } else if (operation == 'edit') {
                            window.location.reload();
                        }
                    } else {
                        Jmts.errorTips(result.msg);
                    }
                });
                return false;
            },
            // submitForm end
            //返回
            returnIndex: function () {
                window.location.href = "/systemNotice/query";
            }
        };
        // 执行初始化
        SystemNoticeMgr.init();
        // 前台验证表单
        $("#systemNoticeForm").validate();
        $('#file_upload').uploadifive({
            'auto': false,
            'buttonClass': 'btn btn-primary',
            'buttonText': "选择文件",
            'queueID': 'uploadqueue',
            'uploadScript': '/file/uploadFiles',
            'onUploadComplete': function (file, data) {
                console.log(data);
            }
        });
    });
</script>
</body>
</html>
